Page({
  onLoad(options) {
   getApp().token && this.getUserInfo()
  },

  // 获取用户信息
  async getUserInfo() {
    const { code, data:{nickName,avatar}} = await wx.http.get('/userInfo')
    if (code !== 10000) return wx.utils.toast()
    this.setData({ nickName, avatar })
    // 存储到全局实例
    getApp().profileInfo = { nickName, avatar }
    
  },
  goLogin() {
    wx.navigateTo({
      url: '/pages/login/index',
    })
  },
})
